<%@ page language="java" 
         contentType="text/html; charset=windows-1256"
         pageEncoding="windows-1256"
         import="CreatorUtil.*"
         import="LoginUtil.*"
         import="java.sql.*"
         import="persistent.*"
         import="com.db4o.ObjectContainer"
         import="com.db4o.ObjectSet"
   %>
 
 <% User currentUser = (User) (session.getAttribute("currentSessionUser"));
 	/* if the current user is null or if he/she is not an Admin, Doctor, or Nurse */
 	if(currentUser == null || !(currentUser.getUserType() == User.UserType.Admin 
 							|| currentUser.getUserType() == User.UserType.Doctor 
 							|| currentUser.getUserType() == User.UserType.Nurse))
 	{
 		response.sendRedirect("login.jsp");
 	}
 	/*gets list of all patients from database*/
 	ObjectContainer container = Db4oServletListener.getObjectContainer(this.getServletContext());
 	User predicate = new User();
 	predicate.setUserType(User.UserType.Patient);
 	ObjectSet<User> userResultSet = container.queryByExample(predicate);
 	/*gets list of all doctors from database*/
 	predicate.setUserType(User.UserType.Doctor);
 	ObjectSet<User> doctorResultSet = container.queryByExample(predicate);
 	/* gets list of all nurses from database */
 	predicate.setUserType(User.UserType.Nurse);
 	ObjectSet<User> nurseResultSet = container.queryByExample(predicate);
 	User tempUser = new User();
 	
 %>
 
   <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
   "http://www.w3.org/TR/html4/loose.dtd">
   
   <html>
      <head>
         <meta http-equiv="Content-Type" 
            content="text/html; charset=windows-1256">
         <title>  New Treatment Record  </title>
         <link rel="stylesheet" type="text/css" href="style.css" />
         
         <script language="javascript" type="text/javascript" src="datetimepicker.js">
				//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
				//Script featured on JavaScript Kit (http://www.javascriptkit.com)
				//For this script, visit http://www.javascriptkit.com 

		</script>
      </head>
   
   <body>
   	<center>
   	<br/><br/><br/><br/>
   	<div id="header">To add a new treatment record, fill out the form below.</div>
   	<br/><br/><br/><br/>
   	
   	<FORM NAME="newtreatmentrecordform" ACTION="NewTreatmentRecordServlet" METHOD="GET">
   		<table>
		<tr>Patient: <select name="patientname">
			<%
				while(userResultSet.hasNext()){
					tempUser = userResultSet.next();
					out.print("<option value='"+tempUser.getUsername()+"'>"+tempUser.getFirstName()+" "+tempUser.getLastName()+"</option>");
				}
			%>
		</select></tr><br>
		<tr>Doctor: <select name="doctorname">
			<%
				while(doctorResultSet.hasNext()){
					tempUser = doctorResultSet.next();
					out.print("<option value='"+tempUser.getUsername()+"'>"+tempUser.getFirstName()+" "+tempUser.getLastName()+"</option>");
				}
			%>
		</select></tr><br>
		<tr>Nurse: <select name="nursename">
			<%
				while(nurseResultSet.hasNext()){
					tempUser = nurseResultSet.next();
					out.print("<option value='"+tempUser.getUsername()+"'>"+tempUser.getFirstName()+" "+tempUser.getLastName()+"</option>");
				}
			%>
		</select></tr><br>
   		<tr>Patient weight: <input type="text" name="weight" value=""></tr><br>
   		<tr>Recommendations: <textarea name="recommendations" cols=30 rows=4></textarea></tr><br>
   		<tr>Date: <input id="demo3" type="text" name="date" value="" size="25"><a href="javascript:NewCal('demo3','ddmmmyyyy',true,24)">
           	   		<img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></tr><br>
        <tr>Paid: <input type="checkbox" name="paid" value="true"></tr><br>
        <tr><input type="submit" name="newtreatmentrecordbutton" value="Create Treatment Record"></tr>
   		
   		</table>
   	</FORM>
   	
   	</center>
   </body>
   
   </html>
   
   
   
   